<!DOCTYPE HTML>
<html>
<head>
    <title>Checkout</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="css/style.css" rel="stylesheet" type="text/css" media="all"/>
    <link href='http//fonts.googleapis.com/css?family=Exo+2' rel='stylesheet' type='text/css'>
    <script type="text/javascript" src="js/jquery1.min.js"></script>
    <script src="js/jquery.cookie.js"></script>
    <!-- start menu -->
    <link href="css/megamenu.css" rel="stylesheet" type="text/css" media="all"/>
    <link href="css/checkbag.css" rel="stylesheet" type="text/css" media="all"/>
    <script type="text/javascript" src="js/megamenu.js"></script>
    <script>$(document).ready(function () {
        $(".megamenu").megamenu();
        $(".header").load("head.html");

        //页面加载回显数据
        var uid = null;
        /*获得session中的对象*/
        $.ajax({
            url: "user/getUser.do",
            type: "POST",
            data: {},
            dataType: "json",
            cache: false,
            success: function (data) {
                if (data != null && (uid = data.id) != null) {
                    $.ajax({
                        url: "bag/findLendingBooks.do",
                        type: "POST",
                        data: {
                            bid: uid,
                        },
                        dataType: "json",
                        cache: false,
                        success: function (data) {
                            for (var i = 0; i < data.length; i++) {
                                var dataStr = "  <div class=\"col_1_of_3 span_1_of_3\" id=\"" + data[i].id + "\" onclick='bookInfo(\"" + data[i].id + "\")'>\n" +
                                    "                        <a href=\"#\">\n" +
                                    "                            <div class=\"inner_content clearfix\">\n" +
                                    "                                <div class=\"product_image\">\n" +
                                    "                                    <img src=\"" + data[i].image + "\" alt=\"\"/>\n" +
                                    "                                </div>\n" +
                                    "                                <div class=\"price\">\n" +
                                    "                                    <div class=\"cart-left\">\n" +
                                    "                                        <p class=\"title\">" + data[i].name + "</p>\n" +
                                    "                                    </div>\n" +
                                    "                                    <div class=\"clear\"></div>\n" +
                                    "                                </div>\n" +
                                    "                            </div>\n" +
                                    "                        </a>\n" +
                                    "                    </div>";

                                if (i == 2) {
                                    dataStr = dataStr + "</div> <div class=\"clear\"></div>  <div class=\"top-box\" id=\"bagOne_2\">";
                                }
                                if (i == 5) {
                                    dataStr = dataStr + "</div> <div class=\"clear\"></div>  <div class=\"top-box\" id=\"bagOne_3\">";
                                }
                                if (i < 3) {
                                    $("#bagOne_1").append(dataStr);
                                } else {
                                    if (i < 6) {
                                        $("#bagOne_2").append(dataStr);
                                    } else {
                                        $("#bagOne_3").append(dataStr);
                                    }
                                }
                            }
                        }
                    });
                } else {
                    alert("请先登录");
                    window.location = "login.html";
                }
            }
        });
        // //获取下面的所有div
        // $(".products>div:eq(" + index + ")").addClass("selected").siblings("div").removeClass("selected");
    });</script>


    <script type="text/javascript">

        /*书本详细信息(点击图片)事件*/
        function bookInfo(bookId) {
            $.cookie("bookId", bookId);
            window.location = "bookInFoBag.html";
        }
    </script>
    <!-- dropdown -->
    <script src="js/jquery.easydropdown.js"></script>
</head>
<body>
<div class="header"></div>
<div class="register_account">
    <div class="wrap mycheckbag">
        <ul class="tab" style="width: 210px">
            <li class="tab-item active">借入中<span>◆</span></li>
            <li class="tab-item">借阅中<span>◆</span></li>
            <li class="tab-item">归还中<span>◆</span></li>

        </ul>
        <div class="products">
            <div class="main selected" id="bagOne_1">
            </div>
            <div class="main" id="bagTwo_1">
            </div>
            <div class="main" id="baThr_1">
            </div>
        </div>
        <script>


            //页面加载事件
            $(function () {
                //获取所有的li标签，同时注册鼠标进入事件
                $(".tab>li").click(function () {
                    //设置当前鼠标进入的li的样式，同时移除当前li的所有兄弟元素的样式
                    $(this).addClass("active").siblings("li").removeClass("active");
                    //设置鼠标进入当前li对应的div的样式
                    //获取当前li的索引值(0为借入中   1为借阅中   2为归还中)
                    var index = $(this).index();
                    var url = null;
                    if (index == "0") {
                        url = "bag/findLendingBooks.do";
                    }
                    if (index == "1") {
                        url = "bag/findLendBooks.do";
                    }
                    if (index == "2") {
                        url = "bag/findReturnBooks.do";
                    }
                    //页面加载回显数据
                    var uid = null;
                    /*获得session中的对象*/
                    $.ajax({
                        url: "user/getUser.do",
                        type: "POST",
                        data: {},
                        dataType: "json",
                        cache: false,
                        success: function (data) {
                            if (data != null && (uid = data.id) != null) {
                                $.ajax({
                                    url: url,
                                    type: "POST",
                                    data: {
                                        bid: uid,
                                    },
                                    dataType: "json",
                                    cache: false,
                                    success: function (data) {
                                        for (var i = 0; i < data.length; i++) {
                                            /*判断书籍是否存在，避免重复拼串*/
                                            if ($("#" + data[i].id + "").length > 0) {
                                            } else {
                                                var dataStr = "  <div class=\"col_1_of_3 span_1_of_3\" id=\"" + data[i].id + "\" onclick='bookInfo(\"" + data[i].id + "\")'>\n" +
                                                    "                        <a href=\"#\">\n" +
                                                    "                            <div class=\"inner_content clearfix\">\n" +
                                                    "                                <div class=\"product_image\">\n" +
                                                    "                                    <img src=\"" + data[i].image + "\" alt=\"\"/>\n" +
                                                    "                                </div>\n" +
                                                    "                                <div class=\"price\">\n" +
                                                    "                                    <div class=\"cart-left\">\n" +
                                                    "                                        <p class=\"title\">" + data[i].name + "</p>\n" +
                                                    "                                    </div>\n" +
                                                    "                                    <div class=\"clear\"></div>\n" +
                                                    "                                </div>\n" +
                                                    "                            </div>\n" +
                                                    "                        </a>\n" +
                                                    "                    </div>";


                                                if (index == "0") {
                                                    if (i == 2) {
                                                        dataStr = dataStr + "</div> <div class=\"clear\"></div>  <div class=\"top-box\" id=\"bagOne_2\">";
                                                    }
                                                    if (i == 5) {
                                                        dataStr = dataStr + "</div> <div class=\"clear\"></div>  <div class=\"top-box\" id=\"bagOne_3\">";
                                                    }
                                                    if (i < 3) {
                                                        $("#bagOne_1").append(dataStr);
                                                    } else {
                                                        if (i < 6) {
                                                            $("#bagOne_2").append(dataStr);
                                                        } else {
                                                            $("#bagOne_3").append(dataStr);
                                                        }
                                                    }
                                                }
                                                if (index == "1") {
                                                    if (i == 2) {
                                                        dataStr = dataStr + "</div> <div class=\"clear\"></div>  <div class=\"top-box\" id=\"bagTwo_2\">";
                                                    }
                                                    if (i == 5) {
                                                        dataStr = dataStr + "</div> <div class=\"clear\"></div>  <div class=\"top-box\" id=\"bagTwo_3\">";
                                                    }
                                                    if (i < 3) {
                                                        $("#bagTwo_1").append(dataStr);
                                                    } else {
                                                        if (i < 6) {
                                                            $("#bagTwo_2").append(dataStr);
                                                        } else {
                                                            $("#bagTwo_3").append(dataStr);
                                                        }
                                                    }
                                                }
                                                if (index == "2") {
                                                    if (i == 2) {
                                                        dataStr = dataStr + "</div> <div class=\"clear\"></div>  <div class=\"top-box\" id=\"baThr_2\">";
                                                    }
                                                    if (i == 5) {
                                                        dataStr = dataStr + "</div> <div class=\"clear\"></div>  <div class=\"top-box\" id=\"baThr_3\">";
                                                    }
                                                    if (i < 3) {
                                                        $("#baThr_1").append(dataStr);
                                                    } else {
                                                        if (i < 6) {
                                                            $("#baThr_2").append(dataStr);
                                                        } else {
                                                            $("#baThr_3").append(dataStr);
                                                        }
                                                    }
                                                }

                                            }

                                        }
                                    }
                                });
                            } else {
                                alert("请先登录")
                            }
                        }
                    });
                    //获取下面的所有div
                    $(".products>div:eq(" + index + ")").addClass("selected").siblings("div").removeClass("selected");
                });
            });
        </script>
        <!--<h4 class="title">书包空空如也</h4>-->
        <!--<p class="cart">去书城看看吧<br>点击<a href="index.html"> 这里</a></p>-->
    </div>
</div>
<div class="footer">
    <div class="footer-bottom">
        <div class="wrap">
            <div class="copy">
                <p>Copyright &copy; 2014.Company name All rights reserved.<a target="_blank"
                                                                             href="http//www.zjf88.com/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a>
                </p>
            </div>
            <div class="f-list2">
                <ul>
                    <li class="active"><a href="about.html">关于我们</a></li>
                    |
                    <li><a href="delivery.html">服务条款</a></li>
                    |
                    <li><a href="contact.html">联系我们</a></li>
                </ul>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
<div style="display:none">
    <script src='http//v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script>
</div>
</body>
</html>